package com.song.service.impl;

import com.song.service.ThreadService;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.stereotype.Service;

import java.util.concurrent.TimeUnit;

/**
 * @Author Klys
 * @Date 2023/7/2 14:41
 * @Description
 * @Version 1.0
 */
@Service
public class ThreadServiceImpl implements ThreadService {
    @Async("myThreadExecutor")
    public String send(String phone) {
        //发短信
        try {
            TimeUnit.SECONDS.sleep(5);
            System.out.println(phone + "线程池发送短信");
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return phone + "线程池发送短信";
    }
}
